package com.imcode;

import java.io.*;

/**
 * 输入转换流，将读取到的字节流，转换成字符流
 * 建立字节到字符的桥梁  解码  看不懂-->看得懂的
 */
public class InputStreamReaderDemo {
    public static void main(String[] args) throws IOException {
        //1.将1_GBK.txt以字节流读入到内存，传递给字节字符转换流
        // 创建流对象,默认UTF8编码
        // Reader isr = new InputStreamReader(new FileInputStream("file/1_GBK.txt"),"GBK");
        // // 创建流对象,指定GBK编码
        Reader isr = new InputStreamReader(new FileInputStream("file/1_GBK.txt"));
        char[] chars = new char[1024];
        int len = isr.read(chars);
        System.out.println(new String(chars,0,len));
        //2.关闭流
        isr.close();
    }
}
